<div id="questionList">
    <script type="text/javascript">
        function delQuestion(idx) {
            $.ajax({
                type: "POST",
                url: "<?php echo url_for('question/deleteUserQuestion') ?>",
                data: "questionId=" + idx + "&available=0",
                success: renderQuestionList
            });

        }
        function cancelDelQuestion(idx) {
            $.ajax({
                type: "POST",
                url: "<?php echo url_for('question/deleteUserQuestion') ?>",
                data: "questionId=" + idx + "&available=1",
                success: renderQuestionList
            });
        }
        function doTop(idx) {
            $.ajax({
                type: "POST",
                url: "<?php echo url_for('question/doTopQuestion') ?>",
                data: "questionId=" + idx + "&top=1",
                success: renderQuestionList
            });
        }
        function doCancelTop(idx) {
            $.ajax({
                type: "POST",
                url: "<?php echo url_for('question/doTopQuestion') ?>",
                data: "questionId=" + idx + "&top=0",
                success: renderQuestionList
            });
        }
        function renderQuestionList(content) {
            $('#questionList').html(content);
        }
    </script>
    <table id="tb_ql" width="805" border="1">
        <tr class="nodrop nodrag">
            <th>ID</th>
            <th>状态</th>
            <th>提问时间</th>
            <th>内容</th>
            <th>用户</th>
            <th>ip</th>
            <th>操作</th>
        </tr>
        <?php foreach ($questions as $question) { ?>
        <tr id="question_<?php echo $question->getId(); ?>">
            <td><?php echo $question->getId(); ?>
                <input type="hidden" name="questionIds[]" value="<?php echo $question->getId(); ?>">
            </td>
            <td>
                <?php
                                                echo '&nbsp';
                if ($question->getIsAvailable() == 0)
                    echo '删除';
                echo '&nbsp';
                if ($question->getIsOnTop() == 1)
                    echo '置顶';
                ?>
            </td>
            <td><?php echo $question->getCreateTime();?></td>
            <td><?php echo $question->getContent();?></td>
            <td><?php echo $question->getUserId();?></td>
            <td><?php echo $question->getIp();?></td>
            <td>
                <?php
                if ($question->getIsOnTop() == 0) {
                    echo '<input type="button" value="置顶" onclick="doTop( ' . $question->getId() . ')">';
                } else
                    echo  '<input type="button" value="取消置顶" onclick="doCancelTop(' . $question->getId() . ')">';

                    if ($question->getIsAvailable() == 1) {
                        echo '<input type="button" value="删除" onclick="delQuestion(' . $question->getId() . ')">';
                    } else
                        echo '<input type="button" value="取消删除" onclick="cancelDelQuestion(' . $question->getId() . ')">'


                    ?>


            </td>
        </tr>
        <?php } ?>
    </table>
</div>

 
